Skip to content

feat(gax): add utility for logging actionable errors#4144

Open
westarle wants to merge 1 commit intogoogleapis:mainfrom
westarle:feat/actionable-errors-logging-utils
Open

feat(gax): add utility for logging actionable errors#4144
westarle wants to merge 1 commit intogoogleapis:mainfrom
westarle:feat/actionable-errors-logging-utils

Conversation

@westarle
Copy link
Contributor

This PR introduces the logActionableError utility method to the core LoggingUtils class within the gax module.

This will be used by an upcoming gRPC interceptor (gax-grpc) and HTTP/JSON interceptor (gax-httpjson).

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Mar 15, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the gax module's logging capabilities by introducing a new utility method designed for logging actionable errors with structured context. This addition is foundational for future gRPC and HTTP/JSON interceptors, enabling more informative and standardized error reporting across the system.

Highlights

  • New Logging Utility: Introduced the logActionableError static method to the LoggingUtils class, enabling structured logging of actionable error messages.
Changelog
  • gax-java/gax/src/main/java/com/google/api/gax/logging/LoggingUtils.java
    • Added the logActionableError static method for structured error logging.
Activity
  • No specific activity (comments, reviews, progress updates) was found in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new utility method logActionableError to LoggingUtils. My review focuses on two main points: the appropriateness of the logging level used and the absence of unit tests for the new functionality, which is required by the repository's contribution guidelines. I've provided specific comments with suggestions for improvement on both fronts.

@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 3722925 to 6ac4725 Compare March 15, 2026 02:43
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 6ac4725 to bbbdfcf Compare March 15, 2026 02:45
@product-auto-label product-auto-label bot added size: s Pull request size is small. size: m Pull request size is medium. and removed size: m Pull request size is medium. size: s Pull request size is small. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from dfa205a to bbbdfcf Compare March 15, 2026 03:05
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: m Pull request size is medium. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from bbbdfcf to 27b0fac Compare March 15, 2026 03:10
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch 2 times, most recently from 999dec3 to 874941b Compare March 15, 2026 03:48
@westarle westarle marked this pull request as ready for review March 15, 2026 04:00
*
* @param enabled true to enable logging, false to disable.
*/
public static void setLoggingEnabled(boolean enabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be package private and annotated with a @VisibleForTesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't seem to be updated?

*
* @return true if logging is enabled, false otherwise.
*/
public static boolean isLoggingEnabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this method remain package private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Map<String, Object> logContext, LoggerProvider loggerProvider, String message) {
if (loggingEnabled) {
org.slf4j.Logger logger = loggerProvider.getLogger();
// Actionable errors are logged at the INFO level because transport errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable errors are logged at the INFO level

Do we have a cross-language requirements for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it down here:

https://docs.google.com/document/d/1H_g63HfgKSYd7nZsnx4-SyT2Hp9iJ5JHm1HwLxBKf6g/edit?resourcekey=0-YjEgJzIczt_Cw3QcVli0Sg&tab=t.0#bookmark=id.bm6k2ftpckjp

Let me know if you have any feedback on it -- it didn't seem appropriate to create error logs at this level.

@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch 2 times, most recently from 1d90782 to 485a1d7 Compare March 18, 2026 03:17
Copy link
Contributor Author

@westarle westarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review!

*
* @return true if logging is enabled, false otherwise.
*/
public static boolean isLoggingEnabled() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*
* @param enabled true to enable logging, false to disable.
*/
public static void setLoggingEnabled(boolean enabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Map<String, Object> logContext, LoggerProvider loggerProvider, String message) {
if (loggingEnabled) {
org.slf4j.Logger logger = loggerProvider.getLogger();
// Actionable errors are logged at the INFO level because transport errors
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it down here:

https://docs.google.com/document/d/1H_g63HfgKSYd7nZsnx4-SyT2Hp9iJ5JHm1HwLxBKf6g/edit?resourcekey=0-YjEgJzIczt_Cw3QcVli0Sg&tab=t.0#bookmark=id.bm6k2ftpckjp

Let me know if you have any feedback on it -- it didn't seem appropriate to create error logs at this level.

@westarle westarle requested a review from blakeli0 March 18, 2026 03:35
@westarle westarle enabled auto-merge (squash) March 18, 2026 03:46
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 485a1d7 to a0df2ff Compare March 18, 2026 04:50
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from a0df2ff to 4a56b8f Compare March 18, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants